//
//  ReferViewController.m
//  Village
//
//  Created by longrise on 2017/9/11.
//  Copyright © 2017年 程虎. All rights reserved.
//


#import "ReferViewController.h"
#import "ReferTableViewCell.h"
#import "CustomCell.h"
#import "LegalPersonTableViewCell.h"
#import "ReferModel.h"
#import "ShowEmptyView.h"
#import "UITableViewCell+FSAutoCountHeight.h"
#import "ReferVailModel.h"
#define CellCount 4
#define ExpandCount 3
@interface ReferViewController ()<UITableViewDataSource, UITableViewDelegate>

@property (nonatomic,strong)UITableView *tableView;
@property (nonatomic,strong)NSMutableArray *sectionArray;
@property (nonatomic,strong)NSMutableArray *flagArray;
@property (nonatomic ,strong)NSArray *titleary;
@property (nonatomic ,strong)UIButton *surebutton;
/**
 左边的数据
 */
@property (nonatomic ,strong)NSArray *oneary;
@property (nonatomic ,strong)NSArray *twoary;
@property (nonatomic ,strong)NSArray *threeary;
/**
 返回的参数
 */
@property (nonatomic ,strong)NSMutableArray *oneary1;
@property (nonatomic ,strong)NSMutableArray *twoary1;
@property (nonatomic ,strong)NSMutableArray *threeary1;
/**
 右边的数据
 */
@property (nonatomic ,strong)NSMutableArray *onearyceshi;
@property (nonatomic ,strong)NSMutableArray *twoaryceshi;
@property (nonatomic ,strong)NSMutableArray *threearyceshi;

@property (nonatomic,strong)UILabel * dizhilable;
@property (nonatomic,strong)NSMutableArray *cellary;
@property (nonatomic,strong)NSMutableArray *nameList;
@property (nonatomic ,strong)NSString *adderss;
@property (nonatomic ,strong)NSString *areaid;
@property (nonatomic,strong)UIView *sectionView;
@property (nonatomic,strong)UILabel *sectionLabel;
@property (nonatomic,strong)UIImageView *arrowImageView;
@end

@implementation ReferViewController

- (void)setParams:(id)obj block:(LongriseRouterBlock)block
{
    NSDictionary *dict = (NSDictionary *)obj;
    NSString *str  = dict[@"province"];
    NSString *str1 = dict[@"city"];
    NSString *str2 = dict[@"district"];
    NSString *str3 = dict[@"town"];
    NSString *str4 = dict[@"village"];
    _areaid = dict[@"areaid"];
    
    if (str1 == nil || [str1 isEqualToString:@""]){
         _adderss = [NSString stringWithFormat:@"%@",str];
    }else if (str2 == nil|| [str2 isEqualToString:@""]) {
         _adderss = [NSString stringWithFormat:@"%@·%@",str,str1];
    }else if (str3 == nil|| [str3 isEqualToString:@""]) {
         _adderss = [NSString stringWithFormat:@"%@·%@·%@",str,str1,str2];
    }else if (str4 == nil|| [str4 isEqualToString:@""]) {
         _adderss = [NSString stringWithFormat:@"%@·%@·%@·%@",str,str1,str2,str3];
    }else{
         _adderss = [NSString stringWithFormat:@"%@·%@·%@·%@·%@",str,str1,str2,str3,str4];
    }
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self gatdata];
}

-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"村落查询";
//    [self getrightbutton];
    self.view.backgroundColor = kBackgroundColor;
    [self makeData];
    _tableView = [[UITableView alloc]  init];
    _tableView.backgroundColor = kBackgroundColor;
    _tableView.delegate = self;
    _tableView.dataSource = self;
    //隐藏滚动条
    _tableView.showsVerticalScrollIndicator = NO;
    _tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
    [_tableView registerClass:[ReferTableViewCell class] forCellReuseIdentifier:@"ReferTableViewCell0"];
    [_tableView registerClass:[ReferTableViewCell class] forCellReuseIdentifier:@"ReferTableViewCell1"];
    [_tableView registerClass:[ReferTableViewCell class] forCellReuseIdentifier:@"ReferTableViewCell3"];
    [_tableView registerClass:[LegalPersonTableViewCell class] forCellReuseIdentifier:@"LegalPersonTableViewCell"];
    [self.view addSubview:_tableView];
    [self Buildthepage];
    
    _surebutton = [UIButton buttonWithType:UIButtonTypeSystem];
    [_surebutton setTitle:@"绑定村落" forState:UIControlStateNormal];
    _surebutton.tintColor = K_Zitihong;
    _surebutton.layer.cornerRadius = 5.0*kScreenScaleX;//2.0是圆角的弧度，根据需求自己更改
    [_surebutton.layer setBorderColor:[UIColor redColor].CGColor];
    _surebutton.layer.borderWidth = 0.5f*kScreenScaleX;//设置边框颜色
    
    _surebutton.titleLabel.font = [UIFont systemFontOfSize:18*kScreenScaleX];
    _surebutton.frame = CGRectMake(30*kScreenScaleX, (KDeviceHeight - 45)*kScreenScaleY, 315*kScreenScaleX, 45*kScreenScaleY);
    //    [_surebutton setBackgroundImage:[UIImage imageNamed:@"BG"]forState:UIControlStateNormal];
    _surebutton.backgroundColor = kBackgroundColor;
    [_surebutton addTarget:self action:@selector(onClickedOKbtn) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:_surebutton];
      if ([Globle getInstance].account.areaid.length > 0){
               _surebutton.hidden = YES;
      }else{
           [_surebutton mas_makeConstraints:^(MASConstraintMaker *make) {
          make.left.equalTo(self.view.mas_left).offset(30*kScreenScaleX);
          make.right.equalTo(self.view.mas_right).offset(-30*kScreenScaleX);
          make.top.equalTo(self.view.mas_bottom).offset(-45*kScreenScaleY);
          make.height.mas_equalTo(45*kScreenScaleY);
         }];
//          [_surebutton mas_makeConstraints:^(MASConstraintMaker *make) {
//
//              make.left.equalTo(self.view.mas_left).offset(30*kScreenScaleX);
//              make.right.equalTo(self.view.mas_right).offset(-30*kScreenScaleX);
//              make.top.equalTo(self.view.mas_bottom).offset(-45*kScreenScaleY);
//              make.height.mas_equalTo(45*kScreenScaleY);
//
//          }];
      }
   
    
}

- (void)getrightbutton{
    UIBarButtonItem *rightBarItem = [[UIBarButtonItem alloc] initWithTitle:@"绑定" style:UIBarButtonItemStylePlain target:self action:@selector(onClickedOKbtn)];
    [rightBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                          [UIFont systemFontOfSize:15], NSFontAttributeName,
                                          [UIColor whiteColor], NSForegroundColorAttributeName,
                                          nil]
                                forState:UIControlStateNormal];
    [rightBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                          [UIFont systemFontOfSize:15], NSFontAttributeName,
                                          [UIColor whiteColor], NSForegroundColorAttributeName,
                                          nil]
                                forState:UIControlStateHighlighted];
    self.navigationItem.rightBarButtonItem = rightBarItem;
}
- (void)onClickedOKbtn{
    if (![Globle getInstance].isNormal){
        NSMutableDictionary *bean = [NSMutableDictionary dictionary];
        NSMutableDictionary *dict = [NSMutableDictionary dictionary];
        [dict setObject:_adderss forKey:@"areaname"];
        [dict setObject:_areaid forKey:@"areaid"];
        [dict setObject:[Globle getInstance].account.leapuserid forKey:@"leapuserid"];
        [bean setValue:dict forKey:@"entitybean"];
        [NetRequestClass Post:bangdinareaidURL Parameters:bean success:^(id result) {
            [MBProgressHUD hideHUDForView:self.navigationController.view];
            [MBProgressHUD showSuccess:result[@"message"] toView:self.navigationController.view Completion:nil];
            [self.navigationController popViewControllerAnimated:YES];
            LSLog(@"msg -----  %@",result);
        } failure:^(id valueCode, id error) {
            [MBProgressHUD hideHUDForView:self.navigationController.view];
            [MBProgressHUD showError:error toView:self.navigationController.view];
        }];
    }else{
        [MBProgressHUD showError:@"暂时不能绑定！" toView:self.navigationController.view];
    }
}
- (void)makeData{
    _flagArray  = [NSMutableArray array];
    _titleary = [NSArray arrayWithObjects:@"组织结构信息",@"法人信息",@"成员信息",@"其他信息", nil];
    _oneary = [NSArray arrayWithObjects:@"统一社会信用代码",@"街道",@"机构类型",@"详细地址",@"原组织结构代码",@"有限期限(始)",@"有限期限(止)",@"核准时间",@"联系人",@"联系电话", nil];
    _twoary = [NSArray arrayWithObjects:@"法定代表人",@"法人身份证号",@"民族",@"党员",@"本科",@"兼任党组织书记", nil];
    _threeary = [NSArray arrayWithObjects:@"村民(居民)小组数",@"户数",@"自然村数", nil];
    _cellary = [NSMutableArray arrayWithObjects:@"ReferTableViewCell",@"ReferTableViewCell",@"LegalPersonTableViewCell",@"ReferTableViewCell", nil];
    _onearyceshi = [NSMutableArray arrayWithObjects:@"unicode",@"orgname",@"orgtype",@"location",@"orgcode",@"orgstartdate",@"orgdeadline",@"checktime",@"contact",@"contactnumber", nil];
//     _onearyceshi = [NSMutableArray arrayWithObjects:@"id",@"orgname",@"orgtype",@"location",@"id",@"orgstartdate",@"orgdeadline",@"checktime",@"contact",@"contactnumber", nil];
    _twoaryceshi = [NSMutableArray arrayWithObjects:@"legalperson",@"legalpersonno",@"nationcn",@"ispartyercn",@"educationcn",@"issecretariescn", nil];
    _threearyceshi = [NSMutableArray arrayWithObjects:@"groupnum",@"registernum",@"villagenum", nil];
    NSInteger num = 4;
    for (int i = 0; i < num; i ++) {
        [_flagArray addObject:@"0"];
    }
}
- (void)gatdata{
    NSMutableDictionary *entitybean = [NSMutableDictionary dictionary];
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
//    [dict setObject:_areaid forKey:@"areaid"];
     [dict setObject:_areaid forKey:@"areaid"];
    [entitybean setValue:dict forKey:@"entitybean"];
    [NetRequestClass Post:getOrgInfoURL Parameters:entitybean success:^(id result) {
        _sectionArray = [NSMutableArray array];
        NSArray *feedDicts = result[@"data"][@"persons"];
        NSMutableArray *entities = @[].mutableCopy;
        [feedDicts enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
            [entities addObject:[[ReferModel alloc] initWithDictionary:obj]];
        }];
        [_sectionArray removeAllObjects];
        for (int i = 0 ; i <entities.count ;i++){
            [_sectionArray addObject:entities[i]];
        }
        _oneary1 = [NSMutableArray array];
        _twoary1 = [NSMutableArray array];
        _threeary1 = [NSMutableArray array];
        
      
        
        for (int i =0 ;i < 10;i++) {
            NSString *str = result[@"data"][@"orginfo"][_onearyceshi[i]];
            if (str == nil){
                     [_oneary1 addObject:@""];
            }else{
                     [_oneary1 addObject:str];
            }

        }
        
        for (int i =0 ;i < 6;i++) {
            NSString *str = result[@"data"][@"legalinfo"][_twoaryceshi[i]];
             if (str == nil){
                  [_twoary1 addObject:@""];
             }else{
                  [_twoary1 addObject:str];
             }
           
        }
        for (int i =0 ;i < 3;i++) {
            NSString *str = result[@"data"][@"other"][_threearyceshi[i]];
            if (str == nil){
                  [_threeary1 addObject:@""];
            }else{
                  [_threeary1 addObject:str];
            }
        }
        dispatch_async(dispatch_get_main_queue(), ^{
            [_tableView reloadData];
        });
           LSLog(@"msg -----  %@",_sectionArray);
    } failure:^(id valueCode, id error) {
        [MBProgressHUD hideHUDForView:self.navigationController.view];
        [MBProgressHUD showError:error toView:self.navigationController.view];
        _tableView.hidden = YES;
        _surebutton.hidden = YES;
        ShowEmptyView *show = [[ShowEmptyView alloc] initWithFrame:CGRectMake(0, 0, kDeviceWidth, KDeviceHeight-100*kScreenScaleY)];
        [self.view addSubview:show];
        
    }];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 4;
}
//组头
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView * sectionView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, KDeviceHeight/13+0.5)];
//    sectionView.backgroundColor=[UIColor colorWithRed:242.0/255 green:80.0/255 blue:59.0/255 alpha:1];
    sectionView.backgroundColor = KRedColors;
    sectionView.tag = 500+section;
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kDeviceWidth, 10)];
    view.backgroundColor = kBackgroundColor;
    self.sectionView = sectionView;
    [sectionView addSubview:view];
    UILabel *sectionLabel = [[UILabel alloc] init];
    sectionLabel.frame = CGRectMake(0, 10, self.view.frame.size.width, KDeviceHeight/16);
    sectionLabel.textColor = [UIColor whiteColor];
    sectionLabel.font = [UIFont systemFontOfSize:16];
    sectionLabel.text = _titleary[section];
    sectionLabel.textAlignment = NSTextAlignmentLeft;
    sectionLabel.tag = 100 + section;
    sectionLabel.userInteractionEnabled = YES;
    //    sectionLabel.backgroundColor = [UIColor whiteColor];
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(sectionClick:)];
    [sectionLabel addGestureRecognizer:tap];
    self.sectionLabel = sectionLabel;
    [sectionView addSubview:sectionLabel];
    
    //展开的小尖头V
    UIImageView  *arrowImageView = [[UIImageView alloc] init];
    
    arrowImageView.tag = 600+section;
    UIImage *img = [UIImage imageNamed:@"1_spread"];
    //根据是否展开显示尖头的方向（向下或向上）
    if (!_flagArray[section]){
        //image的翻转
        img = [UIImage imageWithCGImage:img.CGImage scale:1 orientation:UIImageOrientationRight];
    }
    arrowImageView.image = img;
    self.arrowImageView = arrowImageView;
    [sectionView addSubview:arrowImageView];
    [arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(sectionView.mas_top).offset(28*kScreenScaleX);
        make.right.equalTo(sectionView.mas_right).offset(-23*kScreenScaleX);
        //使顶部与self.ScrollWebView的底部间距为0
        make.width.mas_equalTo(16*kScreenScaleX);;
        make.height.mas_equalTo(8*kScreenScaleY);
        
    }];
    
//    UILabel * linLable=[[UILabel alloc]initWithFrame:CGRectMake(0, KDeviceHeight/13,self.view.frame.size.width , 0.5)];
//    linLable.backgroundColor=[UIColor lightGrayColor];
//    [sectionView addSubview:linLable];
    return sectionView;
}

//组头高度
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return KDeviceHeight/13+0.5;
}
//组尾高度
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0;
}
//cell的高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if ([_flagArray[indexPath.section] isEqualToString:@"0"])
        return 0;
    else
    {
       
//        return [self heightForString:self.sectionArray[indexPath.section][@"content"][indexPath.row][@"text"] andWidth:self.view.frame.size.width];;
        if (indexPath.section == 0){
//            if (indexPath.row == 0){
//                return height*kScreenScaleY;
//            }else{
//                return height*kScreenScaleY;
//            }
            NSString * policy = _oneary1[indexPath.row];
            CGFloat height = [self.title isEqualToString:@"keyCache"]?[ReferTableViewCell FSCellHeightForTableView:tableView indexPath:indexPath cacheKey:policy cellContentViewWidth:0 bottomOffset:0]:[ReferTableViewCell FSCellHeightForTableView:tableView indexPath:indexPath cellContentViewWidth:0 bottomOffset:0];
            return (height + 15) *kScreenScaleX;
        }else
        if (indexPath.section ==2){
            return 110*kScreenScaleY;
        }else{
            return 45*kScreenScaleY;
        }
    }
}

//设置行数
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    if (section == 0){
        return 10;
    }else if (section == 1){
          return 6;
    }else if (section == 2){
          return _sectionArray.count;
    }else{
          return 3;
    }
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    UITableViewCell *cell = nil;
    
    if (indexPath.section == 0){
        cell = [tableView dequeueReusableCellWithIdentifier:@"ReferTableViewCell0"];
        ReferTableViewCell *newcell = (ReferTableViewCell *)cell;
//        if (indexPath.row ==0){
//            newcell.image.hidden = NO;
//            newcell.leftlable.hidden = YES;
//            newcell.rightlable.hidden = YES;
//        }else{
        
            newcell.image.hidden = YES;
            newcell.leftlable.text = _oneary[indexPath.row ];
            
            if ([_oneary1[indexPath.row ] isEqualToString:@"4"]){
                  newcell.rightlable.text = @"村委会";
            }else if ([_oneary1[indexPath.row ] isEqualToString:@"5"]){
                  newcell.rightlable.text = @"居委会";
            }else{
                  newcell.rightlable.text = _oneary1[indexPath.row ];
            }
//        }
    }else if(indexPath.section == 1){
        cell = [tableView dequeueReusableCellWithIdentifier:@"ReferTableViewCell1"];
        ReferTableViewCell *newcell = (ReferTableViewCell *)cell;
        newcell.image.hidden = YES;
        newcell.leftlable.text = _twoary[indexPath.row];
        newcell.rightlable.text = _twoary1[indexPath.row];

    }else if (indexPath.section == 2){
        cell = [tableView dequeueReusableCellWithIdentifier:@"LegalPersonTableViewCell"];
        LegalPersonTableViewCell *newcell = (LegalPersonTableViewCell *)cell;
        newcell.refer = _sectionArray[indexPath.row];
    }else{
        cell = [tableView dequeueReusableCellWithIdentifier:@"ReferTableViewCell3"];
        ReferTableViewCell *newcell = (ReferTableViewCell *)cell;
        newcell.backgroundColor = [UIColor whiteColor];
        newcell.image.hidden = YES;
        newcell.leftlable.text = _threeary[indexPath.row];
        newcell.rightlable.text = _threeary1[indexPath.row];
    }
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];//cell点击之后没有视觉效果
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSLog(@"%@",[NSString stringWithFormat:@"第%ld组的第%ld个cell",(long)indexPath.section,(long)indexPath.row]);
}
//手势点击事件
- (void)sectionClick:(UITapGestureRecognizer *)tap{
    int index = tap.view.tag % 100;
    NSMutableArray *indexArray = [[NSMutableArray alloc]init];
    //    NSArray *arr = _sectionArray[index];
    NSIndexPath *path = [NSIndexPath indexPathForRow:0 inSection:index];
    [indexArray addObject:path];
    
  
        if ([_flagArray[index] isEqualToString:@"0"]) {//展开
            _flagArray[index] = @"1";

            UILabel *lable = (UILabel *)[self.view viewWithTag:100+index];
            lable.textColor = [UIColor whiteColor];
            UIImageView *imageView = (UIImageView *)[self.view viewWithTag:600+index];
            imageView.image = [UIImage imageNamed:@"2_spread"];
            //尖头翻转180度
            //        imageView.transform = CGAffineTransformMakeRotation(M_PI/1);
            
            [_tableView reloadRowsAtIndexPaths:indexArray withRowAnimation:UITableViewRowAnimationBottom];
        } else { //收起
            _flagArray[index] = @"0";
            UIImageView *imageView = (UIImageView *)[self.view viewWithTag:600+index];
            imageView.image = [UIImage imageNamed:@"1_spread"];
            //尖头翻转180度
            //        imageView.transform = CGAffineTransformMakeRotation(0);
            
            [_tableView reloadRowsAtIndexPaths:indexArray withRowAnimation:UITableViewRowAnimationFade]; //使用下面注释的方法就 注释掉这一句
       

    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)Buildthepage{
    
    UIView *head = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kDeviceWidth, 41*kScreenScaleY)];
    head.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:head];
    UIView *footview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kDeviceWidth, 400*kScreenScaleY)];
    footview.backgroundColor = kBackgroundColor;
    _tableView.tableFooterView = footview;
    UIImageView *image = [[UIImageView alloc] init];
    image.image = [UIImage imageNamed:@"location"];
    [head addSubview:image];
    [image mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(head.mas_left).offset(15*kScreenScaleX);//使顶部与self.ScrollWebView的底部间距为0
        make.width.mas_equalTo(15*kScreenScaleX);;
        make.height.mas_equalTo(19*kScreenScaleY);
        make.centerY.equalTo(head);
    }];
    _dizhilable = [[UILabel alloc] initWithFrame:CGRectMake(35, 10, 330, 0)];
    _dizhilable.text = _adderss;
    _dizhilable.numberOfLines = 0;
    _dizhilable.font = [UIFont systemFontOfSize:14];
    [head addSubview:_dizhilable];
    CGFloat hight = [self getHeightByWidth1:330*kScreenScaleX title:_adderss font:_dizhilable.font];
    _dizhilable.frame = CGRectMake(40*kScreenScaleX, 10*kScreenScaleY, 330*kScreenScaleX, hight);
    
    head.frame = CGRectMake(0, 0, kDeviceWidth, 20+hight);
    if (![Globle getInstance].account.areaid.length > 0){
        [_tableView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.view.mas_top).offset(20+hight);//使顶部与self.ScrollWebView的底部间距为0
            make.left.equalTo(self.view.mas_left).offset(8*kScreenScaleX);
            make.right.equalTo(self.view.mas_right).offset(-8*kScreenScaleX);
            make.bottom.equalTo(self.view.mas_bottom).offset(-45*kScreenScaleY);
        }];
    }else{
        [_tableView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.view.mas_top).offset(20+hight);//使顶部与self.ScrollWebView的底部间距为0
            make.left.equalTo(self.view.mas_left).offset(8*kScreenScaleX);
            make.right.equalTo(self.view.mas_right).offset(-8*kScreenScaleX);
            make.bottom.equalTo(self.view.mas_bottom).offset(0*kScreenScaleY);
        }];
    }
    
    
  
    
    

}

- (CGFloat)getHeightByWidth1:(CGFloat)width title:(NSString *)title font:(UIFont *)font
{
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, width, 0)];
    label.text = title;
    label.font = font;
    label.numberOfLines = 0;
    [label sizeToFit];
    CGFloat height = label.frame.size.height;
    return height;
}
/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */


@end
